package com.sect.edu.info.manager.service;

import com.sect.edu.info.manager.dao.TeacherDao;
import com.sect.edu.info.manager.domain.Teacher;

import java.util.ArrayList;

/**
 * @author げっしょく
 * @date 2021/7/19
 */
public class TeacherService {
    TeacherDao teacherDao = new TeacherDao();
    public boolean addteacher(Teacher teacher) {
        return teacherDao.addTeacher(teacher);
    }

    public boolean judgId(String id) {
        ArrayList<Teacher> list = teacherDao.returnList();
        for (int i = 0; i < list.size(); i++) {
            Teacher t = list.get(i);
            if(id.equals(t.getId())){
                return true;
            }
        }
        return false;
    }

    public void delTeacher(String id) {
        ArrayList<Teacher> list = teacherDao.returnList();
        for (int i = 0; i < list.size(); i++) {
            Teacher t = list.get(i);
            if(id.equals(t.getId())){
                list.remove(i);
                return ;
            }
        }
    }

    public ArrayList<Teacher> returnList() {
        return teacherDao.returnList();
    }
}
